<template>
  <lay-container fluid="true" class="roleCount-box">
    <div class="tab-content">
      <lay-form :model="roleCodeBo" ref="formRef" label-width="60" size="sm">
        <lay-form-item label="角色数量" prop="roleCount" required mode="inline">
          <lay-input v-model="roleCodeBo.roleCount" ></lay-input>
        </lay-form-item>
        <lay-form-item label="创建人" prop="createBy" required mode="inline">
          <lay-input v-model="roleCodeBo.createBy" disabled ></lay-input>
        </lay-form-item>
        <lay-form-item label="更新人" prop="updateBy" required mode="inline">
          <lay-input v-model="roleCodeBo.updateBy" disabled ></lay-input>
        </lay-form-item>
        <lay-form-item label="更新时间" prop="createTime" required mode="inline">
          <lay-input v-model="roleCodeBo.createTime" disabled ></lay-input>
        </lay-form-item>
        <lay-form-item label="更新时间" prop="updateTime" required mode="inline">
          <lay-input v-model="roleCodeBo.updateTime" disabled ></lay-input>
        </lay-form-item>
        <lay-form-item label="" style="text-align: center" mode="inline">
          <lay-button type="primary" @click="toUpdateSysConfig">提交</lay-button>
          <lay-button @click="recover">恢复</lay-button>
        </lay-form-item>
      </lay-form>
    </div>
  </lay-container>
</template>
<script setup lang="ts">
import {onMounted, ref} from 'vue'
import {getRoleCountConfig,updateRoleCountConfig} from '@/api/module/config'

const formRef = ref()

// 修改信息
const roleCodeBo = ref({
  roleCount: '',
  createBy: '',
  updateBy: '',
  createTime: '',
  updateTime: '',
});
// 初始化数据
onMounted(()=>{
  initRoleCountConfig();
})

// 获取角色配置
const initRoleCountConfig = function () {
  getRoleCountConfig().then(res=>{
    roleCodeBo.value = res.data;
  })
}

// 编辑角色
const toUpdateSysConfig = function () {
  updateRoleCountConfig(roleCodeBo.value).then(res=>{
    if (res.code === 200) {
      initRoleCountConfig();
    }
  })
}

// 恢复
const recover = function (){
  initRoleCountConfig();
}

</script>

<style scoped>

.tab-content {
  height: 368px;
  max-width: 500px;
  padding: 0 20px;
  background-color: #fff;
}
</style>